package com.dming.testrequest;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jamlu.framework.base.BaseRxStatusActivity;
import com.jamlu.framework.ui.status.StatusSmartRvView;
import com.jamlu.framework.utils.ToastPts;

import butterknife.BindView;
import butterknife.OnClick;

public class MainActivity extends BaseRxStatusActivity<MainPresenter> implements MainView{


    @BindView(R.id.fl_refresh)
    FrameLayout mLlRefresh;
    @BindView(R.id.ll_two)
    RelativeLayout mLlTwo;
    @BindView(R.id.ll_three)
    LinearLayout mLlThree;
    @BindView(R.id.listView)
    ListView mListView;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_main;
    }

    @Override
    protected MainPresenter createPresenter() {
        return new MainPresenter(this);
    }

    @Override
    protected void initData() {
        setTitle("New Framework");
    }

    @Override
    protected void initEvent() {
        getPresenter().injectStatusRequest(mLlTwo);
        getPresenter().injectStatusRequest(mLlThree);
        getPresenter().injectStatusRequest(mListView);
        StatusSmartRvView statusRvView = getPresenter().injectRvStatusRequest(mLlRefresh,new NotificationAdapter(R.layout.item_notification));
        statusRvView.getBaseQuickAdapter().setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ToastPts.show("position: "+position);
            }
        });
        getPresenter().injectStatusNone();
    }

    @OnClick({R.id.testBtn1,R.id.testBtn2})
    public void onViewClicked(View view) {
        if (view.getId() == R.id.testBtn1) {
            getPresenter().injectStatusDialog(true);
        }else if (view.getId() == R.id.testBtn2) {
            getPresenter().injectStatusDialog(false);
        }
    }


    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    public void onSuccess(int code) {
        ToastPts.show("success: "+code);
    }
}
